﻿@model IEnumerable<TbShop.Web.Models.SiteMapViewModels>

<ul class="sidebar-menu">
    @if (Model != null && Model.Any())
    {
        foreach (var item in Model)
        {
            if (item.ChildSiteMapViewModels != null && item.ChildSiteMapViewModels.Any())
            {
                <li class="treeview">
                    <a href="#">
                        <i class="@item.FontClass"></i> <span>@item.Name</span> <i class="fa fa-angle-left pull-right"></i>
                    </a>
                    <ul class="treeview-menu">
                        @if (item.ChildSiteMapViewModels != null && item.ChildSiteMapViewModels.Any())
                        {
                            foreach (var sub in item.ChildSiteMapViewModels)
                            {
                                <li module-id="@sub.ModuleId"><a href="@(Url.Content("~" + sub.Url) )"><i class="@(sub.FontClass ?? "")"></i>@sub.Name</a></li>
                            }
                        }
                    </ul>
                </li>
            }
            else
            {
                <li module-id="@item.ModuleId">
                    <a href="@(item.Url == "#" ? "#" : (Url.Content("~" + item.Url)))">
                        <i class="@item.FontClass"></i> <span>@item.Name</span>
                    </a>
                </li>
            }
        }
    }
</ul>